function S = makepcamodel(vmean, eigvals, V, totalenergy)
%MAKEPCAMODEL Makes the PCA model structure with given information
%
% [ Syntax ]
%   - S = makepcamodel(vmean, eigvals, V, totalenergy, supp)
%
% [ Arguments ]
%   - vmean:            The mean vector
%   - eigvals:          The preserved eigenvalues
%   - V:                The preserved eigenvectors
%   - totalenergy:      The total energy (sum of all eigenvalues)
%   - S:                The PCA model struct with the following
%                       fields:
%                       \{:
%                          - sampledim:     the dimension of samples
%                          - feadim:        the dimension of subspace
%                                           feature
%                          - vmean:         the mean vector
%                          - P:             the projection matrix
%                                           (preserved eigenvectors)
%                          - eigvals:       the vector of preseved eigen values
%                          - total:         the total energy
%                          - preserved:     the preserved energy
%                          - residue:       the residue energy
%                          - energyratio:   the ratio of preserved energy
%                       \:}
%
% [ History ]
%   - Created by Dahua Lin, on Jul 16, 2007
%


preserved = sum(eigvals);

S = struct( ...
    'sampledim', size(V, 1), ...
    'feadim', size(V, 2), ...
    'vmean', vmean, ...
    'P', V, ...
    'eigvals', eigvals, ...
    'total', totalenergy, ...
    'preserved', preserved, ...
    'residue', totalenergy - preserved, ...
    'energyratio', preserved / totalenergy );


